<template>
  <div>
    商品名称：<input type="text" v-model.trim="obj.name">
    商品价格：<input type="text" v-model.number="obj.price">
    商品数量：<input type="text" v-model.number="obj.num">
    <button @click="onClick">添加商品</button>
  </div>
</template>

<script>
import { mapMutations } from 'vuex'
export default {
  data () {
    return {
      obj: {
        name: '',
        price: '',
        num: 0,
        checked: false
      }
    }
  },

  created () {

  },

  methods: {
    ...mapMutations(['addList']),
    onClick () {
      this.addList(this.obj)
    }

  }
}
</script>

<style scoped lang='less'>

</style>
